const app = getApp()
import $service from '../../../../service.js';
Page({

  data: {
    patientList: [],
    relationList: [{
      text: '本人',
      value: '0'
    },{
      text: '父母',
      value: '2'
    },{
      text: '配偶',
      value: '3'
    },{
      text: '子女',
      value: '4'
    },
    // {
    //   text: '朋友',
    //   value: '5'
    // },
    {
      text: '其他',
      value: '1'
    }],
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad() {
    this.getInquiryPatientInfoList()
  },
  // 获取就诊人列表
  getInquiryPatientInfoList() {
    app.http.getInquiryPatientInfoList().then(res => {
      res.data.list.forEach(item => {
          item.relationName = this.data.relationList.filter(ite => ite.value == item.relationType)[0].text
      });
      this.setData({
        patientList: res.data.list
      })
    }).catch(err => {
      $service.showToast(err.msg)
    })
  },
  goHistory(e) {
    let {info} = e.currentTarget.dataset
    $service.openPage(`/pages/doctor_side/index/index_history/index_history?idCard=${info.patientIdcard}&name=${info.patientName}&logId=${info.logId}&type=user`)
  }
})